class CountDown(object):
    def __init__(self, count):
        self.count = count

    def __next__(self):
        if self.count > 0:
            self.count -= 1
            return self.count
        else:
            raise StopIteration

    def __iter__(self):
        return self


def countdown(count):
    counter = CountDown(count)
    for item in counter:
        print(item)


class StrIterator:
    def __init__(self):
        self.iterator = 'abcdefghij'

    def __iter__(self):
        return iter(self.iterator)

    def __next__(self):
        return next(self.iterator)


def str_iterator():
    iterator = StrIterator()
    for item in iterator:
        print(item)


if __name__ == '__main__':
    # countdown(5)
    str_iterator()
